package com.SH.controller;

import com.SH.pojo.Goods;
import com.SH.service.impl.GoodServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @Project:
 * @CreateDate: Created in 2020/3/5 13:39
 * @Author: YXH
 */
@Controller
public class IndexController {

    @Autowired
    GoodServiceImpl goodServiceImpl;

    @RequestMapping("/toShop")
    public String toShop(@RequestParam(name="cid") String cid , Model model){
        int cCid = Integer.valueOf(cid).intValue();
        List<Goods> cidGoods = goodServiceImpl.getCidGoods(cCid);
        for (Goods goods:cidGoods){
            System.out.println(goods);
        }
        model.addAttribute("cid",cid);
        model.addAttribute("cidGoods",cidGoods);
        return "shop";
    }

    @RequestMapping("/toAdmin")
    public String toAdmin(){
        return "admin";
    }

}
